package com.ssmk.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ssmk.R;
import com.ssmk.module.merchant.bean.ShangpinBean;

import java.util.List;

/**
 * Created by Administrator on 2017/9/1 0001.
 */

public class CommodityTypeAdapter extends BaseAdapter {
    private final List<ShangpinBean.DataBean> mList;
    private final Context mContext;

    public CommodityTypeAdapter(Context context, List<ShangpinBean.DataBean> list){
        this.mContext = context;
        this.mList = list;
    }
    @Override
    public int getCount() {
        return mList != null?mList.size():0;
    }

    @Override
    public Object getItem(int i) {
        return mList.get(0);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        CommodityHolder holder;
        if (view == null){
            view = View.inflate(mContext, R.layout.commodity_type_menu_layout,null);
            holder = new CommodityHolder();
            holder.text_type = (TextView)view.findViewById(R.id.commodity_menu_item);
            holder.text_type.setText(mList.get(i).getMasterType());
            view.setTag(holder);
        }else {
            holder = (CommodityHolder)view.getTag();
        }
        return view;
    }
    class CommodityHolder{
        TextView text_type;
    }
}
